package com.lzp.common;

import io.swagger.annotations.ApiModelProperty;

/**
 * @author lzp
 * @version 1.0.0
 * @date 2022/5/8 23:29:24
 * @apiNote
 */
public class Result<T> {
    private Result() {}
    @ApiModelProperty("返回的数据")
    protected T data;
    @ApiModelProperty("状态码")
    protected Integer status;
    @ApiModelProperty("信息")
    protected String message;
    public static <T> Result<T> success(){
        Result<T> tResult = new Result<>();
        tResult.setStatus(1);
        return tResult;
    }
    public static <T> Result<T> success(T t){
        Result<T> tResult = new Result<>();
        tResult.setData(t);
        tResult.setStatus(1);
        return tResult;
    }
    public static <T> Result<T> fail(String message){
        Result<T> tResult = new Result<>();
        tResult.setStatus(0);
        tResult.setMessage(message);
        return tResult;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }
}
